package com.cheng.servlet;

import com.cheng.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ajaxServlet {


    @ResponseBody//吧返回的数据改成json数据，前端直接遍历json,同时告诉spirngmvc此时返回的是数据，不是页面,导入依赖
    @RequestMapping(value = "Ajax")
    public List<Student> Ajax(){
        //service-dao
        //模拟数据
        List<Student> studentLit = new ArrayList<>();
        Student student1=new Student();
        Student student2=new Student();
        Student student3=new Student();
        student1.setSNo(1);
        student2.setSNo(2);
        student3.setSNo(3);
        studentLit.add(student1);
        studentLit.add(student2);
        studentLit.add(student3);
        return studentLit;
    }
}
